#include <bits/stdc++.h>

using namespace std;

const int MAXN = 410;
const int inf = 0x3f3f3f3f;

typedef struct {int v,w,nxt;}edge;

int h[MAXN],d[MAXN],n,p,q,cnt=1,maxflow,now[MAXN],s,t;
edge e[MAXN*MAXN];

void link(int x,int y,int w){
	e[++cnt] = (edge){y,w,h[x]};h[x] = cnt;
	e[++cnt] = (edge){x,0,h[y]};h[y] = cnt;
}

bool bfs(){
	memset(d,0,sizeof(d));
	d[s] = 1,now[s] = h[s];
	queue<int> q;q.push(s);
	while(q.size()){
		int x = q.front();q.pop();
		for(int i = h[x];i;i = e[i].nxt){
			int y = e[i].v;
			if(e[i].w and !d[y]){
				d[y] = d[x] + 1;
				now[y] = h[y];
				q.push(y);
				if(y == t) return 1;
			}
		}
	}
	return 0;
}

int dinic(int x,int flow){
	if(x == t) return flow;
	int res = flow;
	for(int i = now[x];i and res;i=e[i].nxt){
		int y = e[i].v; now[x] = i;
		if(e[i].w and d[y] == d[x] + 1){
			int k = dinic(y,min(res,e[i].w));
			if(!k) d[y] = 0;
			res -= k;
			e[i].w -= k;
			e[i^1].w += k;
		}
	}
	return flow - res;
}

int main (){
	scanf("%d %d %d",&n,&p,&q);
	s = 0,t = n*2+p+q+1;
	for(int i = 1;i <= p;i++) link(s,i,1);
	for(int i = 1;i <= q;i++) link(i+p+n+n,t,1);
	for(int i = 1;i <= n;i++)
		for(int j = 1;j <= p;j++){
			int x;scanf("%d",&x);
			if(x){
				link(j,i+p,1);
			}
		}
	for(int i = 1;i <= n;i++)
		for(int j = 1;j <= q;j++){
			int x;scanf("%d",&x);
			if(x){
				link(i+p+n,j+p+n+n,1);
			}
		}
	for(int i = 1;i <= n;i++) link(i+p,i+p+n,1);
	int flow = 0;
	while(bfs()) while(flow = dinic(s,inf)) maxflow += flow;
	printf("%d\n",maxflow);
	return 0;
}
